package com.stylefeng.guns.modular.stockmanagement.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.GoodsOverflowList;
import com.stylefeng.guns.modular.stockmanagement.service.IGoodsOverflowListService;

/**
 * 商品报溢管理控制器
 *
 * @author fengshuonan
 * @Date 2018-09-19 14:36:23
 */
@Controller
@RequestMapping("/goodsOverflowList")
public class GoodsOverflowListController extends BaseController {

    private String PREFIX = "/stockmanagement/goodsOverflowList/";

    @Autowired
    private IGoodsOverflowListService goodsOverflowListService;

    /**
     * 跳转到商品报溢管理首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "goodsOverflowList.html";
    }

    /**
     * 跳转到添加商品报溢管理
     */
    @RequestMapping("/goodsOverflowList_add")
    public String goodsOverflowListAdd() {
        return PREFIX + "goodsOverflowList_add.html";
    }

    /**
     * 跳转到修改商品报溢管理
     */
    @RequestMapping("/goodsOverflowList_update/{goodsOverflowListId}")
    public String goodsOverflowListUpdate(@PathVariable Integer goodsOverflowListId, Model model) {
        GoodsOverflowList goodsOverflowList = goodsOverflowListService.selectById(goodsOverflowListId);
        model.addAttribute("item",goodsOverflowList);
        LogObjectHolder.me().set(goodsOverflowList);
        return PREFIX + "goodsOverflowList_edit.html";
    }

    /**
     * 获取商品报溢管理列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return goodsOverflowListService.selectList(null);
    }

    /**
     * 新增商品报溢管理
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(GoodsOverflowList goodsOverflowList) {
        goodsOverflowListService.insert(goodsOverflowList);
        return SUCCESS_TIP;
    }

    /**
     * 删除商品报溢管理
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer goodsOverflowListId) {
        goodsOverflowListService.deleteById(goodsOverflowListId);
        return SUCCESS_TIP;
    }

    /**
     * 修改商品报溢管理
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(GoodsOverflowList goodsOverflowList) {
        goodsOverflowListService.updateById(goodsOverflowList);
        return SUCCESS_TIP;
    }

    /**
     * 商品报溢管理详情
     */
    @RequestMapping(value = "/detail/{goodsOverflowListId}")
    @ResponseBody
    public Object detail(@PathVariable("goodsOverflowListId") Integer goodsOverflowListId) {
        return goodsOverflowListService.selectById(goodsOverflowListId);
    }
}
